#include <iostream>
#include <stack>
using namespace std;

stack<int> val;
stack<char> opr;

bool cal()
{
    int num1 = val.top();
    val.pop();
    int num2 = val.top();
    val.pop();
    char op = opr.top();
    opr.pop();
    if (op == '+')
    {
        val.push(num2 + num1);
    }
    else if (op == '-')
    {
        val.push(num2 - num1);
    }
    else if (op == '*')
    {
        val.push(num2 * num1);
    }
    else
    {
        if (num1)
        {
            val.push(num2 / num1);
        }
        else
        {
            cout << "ERROR: " << num2 << "/0";
            return false;
        }
    }
    return true;
}

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int input;
        cin >> input;
        val.push(input);
    }
    cin.get();
    while (--n)
    {
        char op;
        cin >> op;
        opr.push(op);
        cin.get();
    }
    bool goon = true;
    while (!opr.empty() && goon)
    {
        goon = cal();
    }
    if (goon)
    {
        cout << val.top();
    }
    return 0;
}